package com.mybatislearn.utils;

import com.mybatislearn.pojo.Blog;
import com.mybatislearn.pojo.Comment;
import com.mybatislearn.pojo.User;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wangzd
 * @create 2021-11-13 11:58
 */
public class Wangzd {
    public static Blog newBlog(){
        Blog blog = new Blog();
        blog.setId(1);
        blog.setTitle("test blog title");
        blog.setBody("test blog body");
        blog.setAuthor(newUser());
        List<Comment> comments = new ArrayList<>();
        comments.add(newComment());
        blog.setComments(comments);
        Map<String, String> map = new HashMap<>();
        map.put("1", "wangzd");
        blog.setLabels(map);
        return blog;
    }

    public static User newUser(){
        User user = new User();
        user.setId(1L);
        user.setName("wangzd");
        user.setPassword(902020);
        return user;
    }

    public static Comment newComment(){
        Comment comment = new Comment();
        comment.setId("1");
        comment.setBlogId(1);
        comment.setBody("test blog comment body");
        comment.setUser(newUser());
        return comment;
    }
}
